// Author : Ajeng Ritanita Nur Widiati - 091511036

package jtk.project4.fleet.screen.addMaintenanceTask;

import java.sql.SQLException;

import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.PmHist;
import jtk.project4.fleet.event.AddMaintenanceTaskEvent;
import nl.coderight.jazz.Controller;

public class AddMaintenanceTaskController extends Controller{
	private FleetModel fleetModel;
	private AddMaintenanceTaskView addMaintenanceTaskView;

	public void handleEvent(AddMaintenanceTaskEvent evt) throws SQLException {
		PmHist pmHist = fleetModel.getPmHist();
		switch (evt.getType()) {
		case SAVE:
			fleetModel.insertPmHist(pmHist);
			break;
		default:
			propagateEvent(evt);
			break;
		}
	}
	
	@Override
	public void execute() {
		fleetModel = (FleetModel) getModel();
		addMaintenanceTaskView = new AddMaintenanceTaskView();
		setView(addMaintenanceTaskView);
		showView();
	}

}